﻿#pragma once

struct DrawBoundBoxParam
{
	glm::mat4 Mvp;
	glm::vec4 color;
	glm::vec4 bdMin;
	glm::vec4 bdMax;
};

class BoundBoxObject
{
public:
	enum ObjType{ ot_poseBox, ot_boundBox };//RenderSceneModels::PoseBoundBox, RenderObject::BoundBox

    BoundBoxObject()
    {
        m_drawParam.Mvp = glm::mat4(1.0f);
        m_drawParam.color = glm::vec4(0.0);
        m_drawParam.bdMin = glm::vec4(0.0);
        m_drawParam.bdMax = glm::vec4(0.0);
    }

	DrawBoundBoxParam m_drawParam;
	ObjType m_objType;
	std::function<void(bool focus)> m_cb_focus;
	std::function<void(bool select)> m_cb_select;
	virtual void OnFocus(bool focus)
	{
		//obj->OnFocus(focus);
	}
	virtual void OnSelect(bool select)
	{
		//obj->OnSelect(select);
	}
};

class FboColorPick
{
	void Use();
	void End();
	//RenderObject *Find(UINT id);
	FboColorPick(FboColorPick&) = delete;
	void operator=(FboColorPick&) = delete;
public:
	FboColorPick();
	~FboColorPick();

	bool Init();
	void Viewport(UINT x, UINT y, UINT w, UINT h);
	void Draw();
	void Add(BoundBoxObject *box);
	void Clear();
	BoundBoxObject *Pick(UINT x, UINT y);

	GLuint m_fbo;
	GLuint m_colorBuffer;
	GLuint m_depthBuffer;

	UINT m_viewport_x;
	UINT m_viewport_y;
	UINT m_viewport_w;
	UINT m_viewport_h;
	std::vector<BoundBoxObject*> m_boundBoxObjs;
	//std::vector<RenderObject *> m_renderObjs;
};

